﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using ImageProcessing;

namespace Image_Processing_Website
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private List<String> m_imageURLs = null;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);            
            m_imageURLs = new List<String>();
            m_imageURLs.Add(@"http://www.clipart.com/images/guest/flash/200710/image_02.jpg");
            String path = Server.MapPath(string.Format("~/Images/test/" + Utilities.getImageName(m_imageURLs[0])));
            //check if the file is exist in folder or not
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_imageURLs[0]);
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);
            stream.CopyTo(fileStream);
            fileStream.Close();
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}